<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
<c:choose>
	<c:when test="${bean.cmd == 'add' }">
	   <spring:message  code="pim"/> - <spring:message  code="add.project"/>
	</c:when>
	<c:otherwise>
	   <spring:message  code="pim"/> - <spring:message  code="edit.project"/> - <c:out value="${project.name}"></c:out>
	</c:otherwise>
</c:choose>
</title>
<link href="<%= request.getContextPath() %>/css/jquery.ui.all.css" rel="stylesheet" />
<link href="<%= request.getContextPath() %>/css/custom.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/v.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.14.custom.js"></script>
<%@include file="script/pim-util.jsp" %>
<%@include file="script/project-script.jsp" %>
</head>
<body>
<c:if test="${bean.isSigned && bean.isAdmin}">
<div id="all">
<div id="wrapper">
<div id="mainheader">
	<jsp:include page="include/common/headerSignedIn.jsp" />
</div> 
<div id="content-wrapper">
<div id="top-menu">
    <jsp:include page="include/common/topMenuHome.jsp" />
</div>
<div class="pg-left-panel">
     <jsp:include page="include/common/leftMenu.jsp" />
</div>
<div class="right-panel-application">
<form:form action="" method="post" commandName="project"  acceptCharset="UTF-8" 
           enctype="multipart/form-data" onsubmit="return imageValidate('logourl');">
<div style="margin-top: 20px;float: right;width: 680px;">	
	<div class="v-row v-border-bottom" style="padding-top: 10px;">
		<div class="v-row-left" style="margin-left: 10px;">
			<span class="v-title">
				<c:choose>
				<c:when test="${bean.cmd == 'add' }">
				   <spring:message  code="add.project"/>
				</c:when>
				<c:otherwise>
				   <spring:message  code="edit.project"/>
				</c:otherwise>
				</c:choose>
			</span>
		</div>	
	</div>
	
	<div class="v-body">	
	<div class="v-row" id="v-global-message">	
	   <c:if test="${addOK == true }">
	      	<span class="v-global-success-message v-row">
	      	    <span><spring:message  code="handle.add.project.success" /></span>
	      	</span>
	   </c:if>	   
	    <c:if test="${editOK == true }">
	      	<span class="v-global-success-message v-row">
	      	    <span><spring:message  code="handle.edit.project.success" /></span>
	      	</span>
	   </c:if>	   
	</div>
	
	<div style="margin-left: 40px;">		
		<div class="v-row">
			<div class="v-row-left">
			<span class="v-required-title">
			    <spring:message code="title.required.field" />
			</span>
			</div>
		</div>	
		
		<c:if test="${bean.cmd == 'add' }">
		<div class="v-row">		    
			<div class="v-row-center">
				<input type="radio" value="new" name="type" id="new" <c:if test="${type != 'copy'}">checked="checked"</c:if>/>
                <label for="new"><spring:message code="type.new"/></label>
                &nbsp;&nbsp;
                <input type="radio" value="copy" name="type" id="copy" <c:if test="${type == 'copy'}">checked="checked"</c:if> />
                <label for="copy"><spring:message code="type.copy" /></label>
			</div>
		</div>
		
		<div id="copyProject" class="v-row" style="display: none;">
			<div class="v-row-left">
				<span>
				       <spring:message code="title.required.project.copy" />
				</span>
			</div>
			
			<div class="v-row-right eighty">
			    <div style=" margin-left: 40px;">
				<span>
                     <select name="copyProject" class="v-select">                       
                        <c:forEach var="project" items="${bean.projects}">
                         <option value="${project.number}"
                               <c:if test="${copyProjectNumber == project.number}">selected="selected"</c:if>>
                               <c:out value="${project.name}" />
                         </option>
                        </c:forEach>
                     </select>				    
				 </span>								 
				 </div>
			</div>
		</div>
		</c:if>
			
		<div class="v-row">
			<div class="v-row-left">
			<span>
			    <spring:message code="title.required.project.name" />
			</span>
			</div>			
			<div class="v-row-right eighty">
			    <div style=" margin-left: 40px;">
				<span>
				    <form:input id="name" maxlength="100" path="name" cssClass="v-input"/>
				</span>
				<br/>
				<form:errors path="name" cssClass="v-error-message" />
				</div>
			</div>
		</div>
		
		<c:if test="${bean.cmd == 'edit' }">
		<div class="v-row">
			<div class="v-row-left">
			<span>
			    <spring:message code="title.required.project.number" />
			</span>
			</div>			
			<div class="v-row-right eighty">
			    <div style=" margin-left: 40px;">
				<span>
				    <form:input id="number" maxlength="3" path="number" cssClass="v-input" disabled="true"
    					onkeypress="return isDecimal(event)"  />
				</span>
				<br/>
				<form:errors path="number" cssClass="v-error-message" />
				</div>
			</div>
		</div>
		</c:if>
		
		<div class="v-row">
			<div class="v-row-left">
				<span>
				       <spring:message code="title.required.project.customer" />
				</span>
			</div>
			
			<div class="v-row-right eighty">
			    <div style=" margin-left: 40px;">
				<span>
                     <form:select path="customer.customerid" cssClass="v-select">
                        <option value="0"><spring:message code="please.choice" /></option>
                        <c:forEach var="customer" items="${bean.customers}">
                         <option value="${customer.customerid}"
                               <c:if test="${project.customer.customerid == customer.customerid}">selected="selected"</c:if>>
                               <c:out value="${customer.name}" />
                         </option>
                        </c:forEach>
                     </form:select>				    
				 </span>
				 <br/>
				 <form:errors path="customer" cssClass="v-error-message" />
				 </div>
			</div>
		</div>
		
		<div class="v-row">
			<div class="v-row-left">
				<span>
			     	<spring:message code="title.required.project.group" />
				</span>
			</div>
			
			<div class="v-row-right eighty">
			    <div style=" margin-left: 40px;">
				<span>
				<form:select path="group.groupid" cssClass="v-select">
                        <option value="0"><spring:message code="please.choice" /></option>
                        <c:forEach var="group" items="${bean.groups}">
                         <option value="${group.groupid}"
                               <c:if test="${project.group.groupid == group.groupid}">selected="selected"</c:if>>
                               <c:out value="${group.employee.visa}" />
                         </option>
                        </c:forEach>
                 </form:select>						
				 </span>
				 <br/>
				<form:errors path="group" cssClass="v-error-message" />
				 </div>
			</div>
		</div>
		
		<div class="v-row">
			<div class="v-row-left">
				<span>
			     	<spring:message code="title.required.project.status" />
				</span>
			</div>
			
			<div class="v-row-right eighty">
			    <div style=" margin-left: 40px;">
				<span>
				<form:select path="projectStatus.statusid" cssClass="v-select">
                        <option value="0"><spring:message code="please.choice" /></option>
                        <c:forEach var="status" items="${bean.statuses}">
                         <option value="${status.statusid}"
                               <c:if test="${project.projectStatus.statusid == status.statusid}">selected="selected"</c:if>>
                               <c:out value="${status.name}" />
                         </option>
                        </c:forEach>
                 </form:select>						
				 </span>
				 <br/>
				 <form:errors path="projectStatus" cssClass="v-error-message" />
				 </div>
			</div>
		</div>
		
		<div class="v-row">
			<div class="v-row-left">
				<span>
				     <spring:message code="project.languages" />
				</span>
			</div>
			
			<div class="v-row-right eighty">
			     <div style=" margin-left: 40px;">
		         <span>
		              <form:input path="languages" cssClass="v-input"/>
				 </span>
		         <br/>
		         <form:errors path="languages" cssClass="v-error-message" />
		         </div>
		    </div>		    		
		</div>
		
		<div class="v-row">
		    <div class="v-row-left">
		         <span>
		           <spring:message code="title.required.project.startDate"/>
		         </span>
		    </div>
		    
		    <div class="v-row-right eighty">
		         <div style=" margin-left: 40px;">
		         <span>
		              <form:input path="startdate" cssClass="v-input" />
				 </span>
		         <br/>
		         <form:errors path="startdate" cssClass="v-error-message" />
		         </div>
		    </div>
		</div>
		
		<div class="v-row">
			<div class="v-row-left">
				<span>
				     <spring:message code="project.endDate" />
				</span>
			</div>
			
			<div class="v-row-right eighty">
			     <div style=" margin-left: 40px;">
		         <span>
		              <form:input path="enddate" cssClass="v-input"/>
				 </span>
		         <br/>
		         <form:errors path="enddate" cssClass="v-error-message" />
		         </div>
		    </div>		    		
		</div>
		
		<div class="v-row">
			<div class="v-row-left">
			   <span><spring:message code="project.logourl" /></span>			   
			</div>			
			<div class="v-row-right eighty">								
				<div style="margin-left: 40px;">
					<span>
						<input class="v-input" type="file" id="logourl" name="logourl" 
						       onchange="imagePreview('logourl', 'image-preview')" size="46"/>
					</span>					
					<br/>
					<form:errors path="logourl" cssClass="v-error-message" />					
				</div>
			</div>
		</div>
		
		<div class="v-row">
		  <div class="v-row-left" style="border: thin ridge #E0EDF4;">					
				<div class="new-manage-org-logo-org">	
				   <c:choose>
				   <c:when test="${addOK == true || bean.cmd == 'edit' }">					      
				      <c:set value="members.htm?pnum=${project.number}&tab=listMembers" var="url"></c:set>   			    				        				     
					  <a href="${url}">				     
					  <c:set var="smallImageUrl" value="${project.logourl}" />
					  <c:choose>
							<c:when test="${smallImageUrl == null || smallImageUrl == '' }">
								<img id="image-preview"  alt="" src="<%=request.getContextPath()%>/images/small_noImage.gif" 
								     onLoad='scaleImg(this, 80, 80)' />
							</c:when>							
							<c:otherwise>
								<img id="image-preview" alt="" src='<c:out value="${smallImageUrl}"></c:out>' 
								     onLoad='scaleImg(this, 80, 80)'>
							</c:otherwise>
					  </c:choose>
					  </a>
				   </c:when>
				   <c:otherwise>
				        <img id="image-preview"  alt="" src="<%=request.getContextPath()%>/images/small_noImage.gif" 
								     onLoad='scaleImg(this, 80, 80)' />
				   </c:otherwise>
				   </c:choose>					
				</div>				
		  </div>
		  <div class="v-row-right eighty">
		    <div style="margin-left: 40px;">
		     <span class="v-info"><spring:message code="warning.project.logo" /></span>
		    </div>
		  </div>
		</div>
		
		<div class="v-row">
		    <br/>
			<div class="v-row-center">
				<span>
				<input type="submit" class="bt-form" 
					        value="<spring:message code="button.save" />" />
				</span>				
				<span>
				<input type="button" class="bt-form"
						onclick="cancel('<c:out value='${bean.returnToFullPageURL }'/>')"
						value="<spring:message code="button.cancel"/>" />
				</span>
			</div>
		</div>
	</div>
</div>
</div>
<input type="hidden" name="cmd" value="${bean.cmd}"/>
<input type="hidden" name="returnToFullPageURL" value="${bean.returnToFullPageURL}"/>
</form:form>
</div>	
</div>
</div>
<div class="footer">
	 <jsp:include page="include/common/footer.jsp" />
</div>
</div>
</c:if>
</body>
</html>